<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

if (env('APP_ENV', 'dev') === 'dev') {
    return [
        'default' => [
            'handler' => [
                'class' => \Monolog\Handler\RotatingFileHandler::class,
                'constructor' => [
                    'filename' => BASE_PATH . '/runtime/logs/hyperf.log',
                    'level' => Monolog\Logger::DEBUG,
                ],
            ],
            'formatter' => [
                'class' => Monolog\Formatter\LineFormatter::class,
                'constructor' => [
                    'format' => null,
                    'dateFormat' => null,
                    'allowInlineLineBreaks' => true,
                ],
            ],
        ],
    ];
} else {
    return [
        'default' => [
            'handler' => [
                'class' => \App\Common\GelfHandler::class,
                'constructor' => [
                    'host' => env('GRAYLOG_HOST', '127.0.0.1'),
                    'port' => env('GRAYLOG_PORT', 12201),
                    'transportType' => env('GRAYLOG_TRANSPORT_TYPE', 'udp'),
                    'level' => env('GRAYLOG_LOG_LEVEL', 'debug'),
                ],
            ],
            'formatter' => [
                'class' => \Monolog\Formatter\GelfMessageFormatter::class,
                'constructor' => [
                    'systemName' => env('APP_NAME')
                ],
            ],
        ],
    ];
}
